package com.bupt.liutong.admin.shop.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.bupt.liutong.admin.core.base.BaseAction;
import com.bupt.liutong.admin.core.form.UserForm;
import com.bupt.liutong.admin.shop.bo.OrderBo;
import com.bupt.liutong.util.StringUtils;

public class OrderAction extends BaseAction {
	private OrderBo orderBo;
	
	public ActionForward confirmOrder(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		UserForm sessionForm = (UserForm) request.getSession().getAttribute("userForm");
		if (sessionForm == null
				|| StringUtils.isEmpty(sessionForm.getUserName())) {
			ActionForward forward = mapping.findForward("login");
			String path = forward.getPath()+"?redirectUrl=/front/shop/order.do?method=confirmOrder";
			return new ActionForward(forward.getName(), path, forward.getRedirect(), forward.getContextRelative());
		} else {
			orderBo.insertOrder(sessionForm);
			return null;
		}
	}

	public void setOrderBo(OrderBo orderBo) {
		this.orderBo = orderBo;
	}
}
